<template>
  <van-sticky :offset-top="0">
    <div class="app-header f-r ai-c jc-sb">
      <van-icon name="arrow-left" :size="18" @click="goBack" />
      <p class="title">{{ title }}</p>
      <div>
        <van-icon v-if="showRight" name="home-o" :size="18" @click="goHome" />
      </div>
    </div>
  </van-sticky>
</template>
<script>
export default {
  name: 'HEADER',
  props: {
    title: {
      type: String,
      default: 'calmax'
    },
    showRight: {
      type: Boolean,
      default: true
    },
    onRightClick: {
      type: Function,
      default: null
    }
  },
  methods: {
    goBack () {
      window.history.go(-1)
    },
    goHome () {
      if (this.onRightClick) {
        this.onRightClick()
        return
      }
      this.$Jump2('home')
    }
  }
}
</script>
<style lang="less" scoped>
.app-header {
  height: 44px;
  line-height: 44px;
  padding: 0 16px;
  background: #fff;
  .title {
    font-size: 15px;
    font-weight: bolder;
  }
}
</style>